#!/usr/bin/env python
#-*- coding:utf-8 -*-
'''
   AddrBookEntry.py
   autor wenzhui
'''
class AddrBookEntry(object):
    print "first Class"
    a = 10
    def __init__(self, nm, ph):
        self.nm = nm
        self.ph = ph 
        print 'hhh ',self.nm
    
    def updatePhone(self,ph):
        self.ph = ph
        print 'hhh ',self.nm

    def sayVersion(cls,ver):
        print "%s , %s" % (ver,cls.__name__)
    
    sayVersion = classmethod(sayVersion)

    @classmethod
    def sayClassName(cls):
        print cls.__name__

    def sayHello(word):
        print 'Hello %s!' % (word)
    
    sayHello = staticmethod(sayHello)

    @staticmethod
    def sayBye():
        print "Bye!"



addr = AddrBookEntry('wenzui','12345678901')
addr2 = AddrBookEntry('we5','12345678')

print addr
print addr.nm
print addr.a
print addr2.a
AddrBookEntry.a = 12
print addr2.a
addr2.a =20
print addr2.a
print AddrBookEntry.a
print dir(AddrBookEntry)
print "attrs == " , AddrBookEntry.__dict__
print "class == " , addr.__class__
print "class == " , AddrBookEntry.__class__
print "name == ", AddrBookEntry.__name__
print "doc == " ,AddrBookEntry.__doc__
print "module == " , AddrBookEntry.__module__


#AddrBookEntry,_AddrBookEntry.__init__(addr2,'asd','asdf')
AddrBookEntry.sayVersion('1.0')
AddrBookEntry.sayClassName()
AddrBookEntry.sayHello('World')
AddrBookEntry.sayBye()



class CN_AddrBookEntry(AddrBookEntry):
    
    def __init__(self, nm, ph, addr):
        AddrBookEntry.__init__(self, nm, ph)
        #super(AddrBookEntry ,self).__init__()# 无法参数调用，蛋疼
        self.addr = addr

    def updateAddr(self, addr):
        self.addr = addr

    def printName(self):
        print "name : " , self.nm

cn_addr = CN_AddrBookEntry('devin', '1235' , 'beijing')
print CN_AddrBookEntry.__bases__



print "CN_Addr is Addr subclass, " , issubclass(CN_AddrBookEntry,AddrBookEntry)

print "cd_addr is AddrBookEntry , ", isinstance(cn_addr , AddrBookEntry)




print hasattr(cn_addr, 'nm')
print hasattr(addr, 'nm')
cn_addr.printName()
print vars(cn_addr)
print (cn_addr.__dict__)

